<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->unsignedInteger('created_user_id')->default('0')->comment('管理员ID');
            $table->string('name', 30)->default('')->comment('管理员姓名');
            $table->string('username', 50)->default('')->comment('登录用户名');
            $table->string('password', 60)->default('')->comment('密码');
            $table->string('randstr', 20)->default('')->comment('加密盐');
            $table->string('phone_number', 30)->default('')->comment('联系电话');
            $table->string('email', 50)->default('')->comment('电子邮箱');
            $table->unsignedInteger('avatar_image')->default('0')->comment('头像，来源附件表ID');
            $table->string('description', 200)->default('')->comment('介绍');
            $table->unsignedTinyInteger('sys')->default('0')->comment('是否为系统管理员0否 1是；数据字典');
            $table->timestamp('last_login_time')->nullable()->comment('最近登录时间');
            $table->tinyInteger('login_fail_times')->nullable()->default(0)->comment('登录错误次数');
            $table->tinyInteger('status')->default(1)->comment('发布状态，0未发布，1已发布 ，数据字典');
            $table->rememberToken()->nullable(false)->default('')->comment('记住我用户存储令牌');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('更新时间');
            $table->softDeletes()->comment('删除时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user');
    }
}
